/*
 * BoxOfficeDAO
 */
package fr.cinescope2014.daos;

import fr.cinescope2014.modeles.BoxOffice;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author formation
 */
public class BoxOfficeDAO {

    private Connection icn;

    public BoxOfficeDAO(Connection icn) {
        this.icn = icn;
    }

    /**
     *
     * @return
     */
    public List<BoxOffice> selectAll() {
        List<BoxOffice> listeBoxOffice = new ArrayList();

        String lsSQL = "CALL box_office()";
        try {
            PreparedStatement lpst = icn.prepareStatement(lsSQL);
            ResultSet lrs = lpst.executeQuery();
            BoxOffice bo;
            while (lrs.next()) {
                bo = new BoxOffice(lrs.getString(1), lrs.getString(2));
                listeBoxOffice.add(bo);
            }
            lrs.close();
            lpst.close();
        } catch (SQLException ex) {
            System.out.println(ex);
        }

        return listeBoxOffice;
    }
} /// BoxOfficeDAO
